package com.santu.edu.supporter.biz.category.dao;

import com.santu.edu.supporter.biz.category.dao.mapper.GoodCategoryMapper;
import com.santu.edu.supporter.biz.category.pojo.dto.GoodCategoryDTO;
import com.santu.edu.supporter.biz.category.pojo.po.GoodCategoryPO;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author luoyaoqi
 * @createTime 2024/3/12
 * @description
 */
@RestController
@RequiredArgsConstructor
public class GoodCategoryDao {

    private final GoodCategoryMapper goodCategoryMapper;
    public void addGoodCategory(GoodCategoryDTO dto) {
        GoodCategoryPO item =  GoodCategoryPO.createItem(dto);
        goodCategoryMapper.insertOne(item);
    }

    public void updateGoodCategory(GoodCategoryDTO dto) {
        GoodCategoryPO item =  GoodCategoryPO.createItem(dto);
        goodCategoryMapper.updateOne(item);
    }

    public void removeGoodCategory(String categoryId) {
        goodCategoryMapper.removeOne(categoryId);
    }

    public List<GoodCategoryDTO> getGoodCategoryList() {
        return goodCategoryMapper.selectGoodCategoryMapper();
    }
}
